package com.slunk.utilities;

import com.badlogic.gdx.scenes.scene2d.ui.Label;

public class ScoreLabel extends Label {
	
	private int score;
	private String baseString;
	private int pointStreak;
	private int lostStreak;
	
	public ScoreLabel(CharSequence text, LabelStyle style) {
		super("", style);
		this.baseString = text.toString();
		this.score = 0;
		this.pointStreak = 0;
		this.lostStreak = 0;
		this.setText(this.baseString + Integer.toString(this.score));
	}
	
	public void setScoreTo(int points) {
		this.score = points;
		this.updateScoreLabel();
	}
	
	public void addToScore(int points) {
		this.score += points;
		this.updateScoreLabel();
		
		this.lostStreak = 0;
		this.pointStreak = this.pointStreak + points;
	}
	
	public void subtrackFromScore (int points) {
		this.score -= points;
		this.updateScoreLabel();
		
		this.pointStreak = 0;
		this.lostStreak = this.lostStreak + points;
	}
	
	public int getWinStreak() {
		return this.pointStreak;
	}
	
	public int getLostStreak() {
		return this.lostStreak;
	}
	
	public void resetStreaks() {
		this.lostStreak = 0;
		this.pointStreak = 0;
	}
	
	public int currentScore() {
		return this.score;
	}
	
	private void updateScoreLabel() {
		this.setText(this.baseString + Integer.toString(this.score));
	}
}
